package handlers

import (
	"github.com/gin-gonic/gin"
	"role/models"
)

func RoleAdd(c *gin.Context) {
	juesename := c.PostForm("juesename")
	jueseqx := c.PostForm("jueseqx")
	role := models.Role{
		JueSeName: juesename,
		JueSeQx:   jueseqx,
	}

	err := models.DB.Create(&role).Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 0,
			"msg":  "添加失败",
		})
		return
	}
	if err != nil {
		c.JSON(200, gin.H{
			"code": 200,
			"msg":  "登录成功",
		})
		return
	}
}
func RoleList(c *gin.Context) {

	var role models.Role
	err := models.DB.Find(&role).Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 0,
			"msg":  "查询失败",
		})
		return
	}
	if err != nil {
		c.JSON(200, gin.H{
			"code": 200,
			"msg":  "查询成功",
		})
		return
	}
}
